//package com.wxzl.community.common.utils.ext
//
//import android.app.Activity
//import android.webkit.WebChromeClient
//import android.webkit.WebViewClient
//import android.widget.Toast
//import com.alibaba.baichuan.android.trade.AlibcTrade
//import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback
//import com.alibaba.baichuan.android.trade.model.AlibcShowParams
//import com.alibaba.baichuan.android.trade.model.OpenType
//import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType
//import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult
//import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams
//import com.alibaba.baichuan.trade.biz.login.AlibcLogin
//import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback
//import com.alibaba.baichuan.trade.common.utils.AlibcLogger
//import java.util.*
//
//
//
///**
// * 淘宝客链接打开
// */
//fun String?.alibuy(activity: Activity) {
//    if (this.isNullOrEmpty()){
//        activity.showToast("优惠券已失效")
//        return
//    }
//    val session = AlibcLogin.getInstance().session
//    session.toJsonString().log()
//    if (session.topAuthCode== null){
//        AlibcLogin.getInstance().showLogin(object : AlibcLoginCallback {
//            override fun onSuccess(result: Int, userId: String, nick: String) {
//                userId.log()
//                nick.log()
//
//               jumpToTaoBao(activity,this@alibuy)
//            }
//            override fun onFailure(i: Int, s: String) {
//                i.log()
//                s.log()
//                Toast.makeText(activity, s, Toast.LENGTH_SHORT).show()
//            }
//        })
//    }else{
//        jumpToTaoBao(activity,this)
//    }
//
//}
//
//private fun jumpToTaoBao(activity: Activity,link: String){
//    val showParams = AlibcShowParams()
//    showParams.openType = OpenType.Auto
//    showParams.clientType = "taobao"
//    showParams.backUrl = ""
//    showParams.nativeOpenFailedMode = AlibcFailModeType.AlibcNativeFailModeJumpH5
//    val taokeParams = AlibcTaokeParams("", "", "")
//    taokeParams.setPid("mm_14333703_2308250455_111376800099")
//    val trackParams: Map<String, String> = HashMap()
//    // 通过百川内部的webview打开页面
//    AlibcTrade.openByUrl(activity,
//        "",
//        link,
//        null,
//        WebViewClient(),
//        WebChromeClient(),
//        showParams,
//        taokeParams,
//        trackParams,
//        object : AlibcTradeCallback {
//            override fun onTradeSuccess(tradeResult: AlibcTradeResult) {
//                AlibcLogger.i("taobaoke", "request success")
//            }
//
//            override fun onFailure(code: Int, msg: String) {
//                AlibcLogger.e("taobaoke", "code=$code, msg=$msg")
//                msg.log()
//                if (code == -1) {
//                    Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show()
//                }
//            }
//        })
//
//}
//
